package gov.kqqzyyy.monkey.clinicscreen.broadcast;

import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import java.util.Objects;

import gov.kqqzyyy.monkey.clinicscreen.ui.MainActivity;

/**
 * Created by Monkey on 2017/10/21.
 * 下载完成接收器
 */

public class DownLoadReceiver extends BroadcastReceiver {

    private final Context mContext;

    public DownLoadReceiver(Context context) {
        mContext = context;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if (Objects.equals(intent.getAction(), DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
            if (mContext instanceof MainActivity) {
                ((MainActivity) mContext).cancelProgressDialog();
            }
            Intent broadIntent = new Intent("toUpdateService");
            broadIntent.putExtra("toservice", 0x13);
            mContext.sendBroadcast(broadIntent);//发送安装通知
        }
    }
}
